export enum AutheConstant {
    LOGIN_TOKEN = "token"
}

export class AutheUtils {

    static hasAuthed(): boolean {

        let token = sessionStorage.getItem(AutheConstant.LOGIN_TOKEN);

        if (!token) {
            return false;
        }

        return true
    }

    static getToken(): string | any {

        let token = sessionStorage.getItem(AutheConstant.LOGIN_TOKEN);

        if (!token) {
            return null;
        }

        return token
    }

    static setToken(token: string): boolean {
        try {
            sessionStorage.setItem(AutheConstant.LOGIN_TOKEN, token);

            return true
        } catch (error) {
            return false
        }

    }

    static removeToken(): string {
        const token = AutheUtils.getToken();
        if(token){
            sessionStorage.removeItem(AutheConstant.LOGIN_TOKEN);
        }
        return token;
    }
}